/* 
 * File:   Common.h
 * Author: artem
 *
 * Created on November 17, 2011, 12:04 AM
 */

#ifndef COMMON_H
#define COMMON_H

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>

#include "Types.h"
#include "Log/Log.h"

#define ASSERT(x) if (!(x)) { LOG_ERROR("Assertion " #x "\n"); assert(x); }

#define ARRAYSIZE(a) (sizeof(a)/sizeof(*(a)))

inline hash_t strhash(const char *str)
{
	hash_t hash = 0;
	
	if (str) while (char c = *str++)
		hash = c + (hash << 6) + (hash << 16) - hash;
	
	return hash;
}

#endif /* COMMON_H */
